package leetcode.code1861;

import leetcode.IDebug;
import leetcode.helper.H;

public class Solution implements IDebug {

	final char STONE = '#';
	final char OBSTACLE = '*';
	final char EMPTY = '.';

	public char[][] rotateTheBox(char[][] box) {
		int m = box.length, n = box[0].length;
		for (int i = 0; i < m; i++) {
			for (int j = n - 1, range = n; j >= 0; j--) {
				char cur = box[i][j];
				if (cur == this.STONE) {
					box[i][j] = this.EMPTY;
					box[i][--range] = cur;
				} else if (cur == this.OBSTACLE) {
					range = j;
				}
			}
		}
		char[][] ans = new char[n][m];
		for (int i = 0; i < m; i++) {
			int ansj = m - 1 - i;
			for (int j = 0; j < n; j++) {
				ans[j][ansj] = box[i][j];
			}
		}
		return ans;
	}

	@Override
	public void debug4() {
		this.rotateTheBox(H.str2array5("[[\"#\",\".\",\"#\"]]"));

	}

	@Override
	public void debug3() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug2() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug1() {
		// TODO Auto-generated method stub

	}

	public static void main(String[] args) {
		Solution so = new Solution();
		so.debug1();
		so.debug2();
		so.debug3();
		so.debug4();

	}

}
